<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
 <!DOCTYPE html>
<html>

<head>
	<base href="/">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    

    <title>关健字分组列表</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="static/templet/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="static/templet/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="static/templet/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="static/templet/css/animate.min.css" rel="stylesheet">
    <link href="static/templet/css/style.min862f.css?v=4.1.0" rel="stylesheet">
<style>
.clearfix:after{
	content:'';
	display:block;
	clear:both;
}
.goBack{
	float:left;
	width:50px;
	margin-top:20px;
}
.pag{
width:90%;
	float:right;
}
</style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
    <form action="keyWord/group/list" method="post" id="billForm">
        <div class="row">  
            <div class="col-sm-12">
                <div class="ibox">
                    <div class="ibox-content">
                      <a class="btn btn-primary " href="javascript:add();" target="_self">新增</a>
                        <table class="table table-hover">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>分组名称</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
							<c:forEach items="${page.list}" var="ba" varStatus="vs">
                            	<tr>
                                    <td>${ba.id}</td>
									<td>${ba.name }</td>
									<td><a class="fa fa-edit" href="javascript:edit('${ba.id }')" title="编辑"></a> 
                                    <a class="fa fa-trash-o" href="javascript:deleteGroup('${ba.id}');" title="删除"></a></td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                        
                        <jsp:include page="/WEB-INF/jsp/page.jsp">
                        	<jsp:param value="billForm" name="form"/>
                        </jsp:include>
                    </div>
                </div>
            </div>
        </div>
        </form>
    </div>
    <script src="static/templet/js/jquery.min.js?v=2.1.4"></script>
    <script src="static/templet/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="static/templet/js/plugins/peity/jquery.peity.min.js"></script>
    <script src="static/templet/js/plugins/layer/layer.min.js"></script>
    <script src="static/templet/js/iframe.min.js"></script>
    <script src="static/templet/js/plugins/layer/laydate/laydate.js"></script>
    <script type="text/javascript">
    function searchs() {
    	$("#billForm").submit();
    }
    
    function add(){
    	parent.layer.open({
    	    type: 2,
    	    title: '添加分组',
    	    shadeClose: true,
    	    shade: 0.8,
    	    area: ['25%', '40%'],
    	    content: 'keyWord/group/toAdd',
    	    cancel:function(index, layero){
    	    	location.reload(true);
    	    }
    	});
    }
    
    function edit(id){
    	parent.layer.open({
    	    type: 2,
    	    title: '编辑分组',
    	    shadeClose: true,
    	    shade: 0.8,
    	    area: ['25%', '40%'],
    	    content: 'keyWord/group/toUpdate?id='+ id,
    	    cancel:function(index, layero){
    	    	location.reload(true);
    	    }
    	});
    }
    
    function deleteGroup(id) {
		parent.layer.confirm('确定要删除此分组吗？', {
		    btn: ['确定','取消'], //按钮
		    shade: false //不显示遮罩
		}, function(){
			   var url = "keyWord/group/deleteGroup?id=" + id;
                $.get(url, function (data) {
                    if (data == "success") {
                    	parent.layer.msg('删除完成', {icon: 1});
                    	location.reload();
                    } else if(data == "exist"){
                    	parent.layer.msg('请移除此分组下关键词', {icon: 2});
                    } else {
                    	parent.layer.msg('删除失败', {icon: 2});
                    }
                }); 
		}, function(){});
	}
    </script>

</body>

</html>